<?php
/* @var $this ChuongtrinhController */
/* @var $model Chuongtrinh */
/* @var $form CActiveForm */
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'chuongtrinh-form',
	// Please note: When you enable ajax validation, make sure the corresponding
	// controller action is handling ajax validation correctly.
	// There is a call to performAjaxValidation() commented in generated controller code.
	// See class documentation of CActiveForm for details on this.
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Điền đầy đủ vào vị trí có dấu <span class="required">*</span>.</p>

	<?php echo $form->errorSummary($model); ?>

<table>
	<div class="row">
	<tr>
		<td style="width:20%"><?php echo $form->labelEx($model,'stt'); ?></td>
		<td><?php echo $form->textField($model,'stt'); ?></td>
		<td><?php echo $form->error($model,'stt'); ?></td>
	</tr>
	</div>

	<div class="row">
	<tr>
		<td><?php echo $form->labelEx($model,'hocki'); ?></td>
		<td><?php
			$hocki=array();
			for($i=1;$i<=8;$i++)
				$hocki[$i]=$i;
			echo $form->dropDownList($model,'hocki',$hocki,array('empty'=>'')); ?></td>
		<td><?php echo $form->error($model,'hocki'); ?></td>
	</tr>
	</div>

	<div class="row">
	<tr>
		<td><?php echo $form->labelEx($model,'mamh'); ?></td>
		<td><?php
			$connection=Yii::app()->db;   // assuming you have configured a "db" connection
			$command=$connection->createCommand()
			->select('mamh,tenmh')
			->from('monhoc')
			//->where(array('and','username="'.$this->username.'"','level>0'))
			->query();
			$hocphan= array();
			foreach($command as $row)
			{
				//array_push($ngach,$row);
				$hocphan[$row['mamh']]=$row['tenmh'];
			}
		
		echo $form->dropDownList($model,'mamh',$hocphan,array('empty'=>'')); ?></td>
		<td><?php echo $form->error($model,'mamh'); ?></td>
	</tr>
	</div>

	<div class="row">
	<tr>
		<td><?php echo $form->labelEx($model,'madonvi'); ?></td>
		<td><?php
		$commandDV=$connection->createCommand()
					->select('madonvi,tendonvi,thuocSGU')
					->from('donvicongtac')
					->query();
					$khoa= array();
					foreach($commandDV as $rowDV)
					{
						//array_push($ngach,$row);
						if($rowDV['thuocSGU']==1)
						{
						$khoa[$rowDV['madonvi']]=$rowDV['tendonvi'];}
					}
		
		echo $form->dropDownList($model,'madonvi',$khoa,array('empty'=>'')); ?></td>
		<td><?php echo $form->error($model,'madonvi'); ?></td>
	</tr>
	</div>
	
	<div class="row">
	<tr>
		<td><?php echo $form->labelEx($model,'madonviday'); ?></td>
		<td><?php
		$commandDV=$connection->createCommand()
					->select('madonvi,tendonvi,laKhoa')
					->from('donvicongtac')
					->query();
					$khoa= array();
					foreach($commandDV as $rowDV)
					{
						//array_push($ngach,$row);
						if($rowDV['laKhoa']==1)
						{
						$khoa[$rowDV['madonvi']]=$rowDV['tendonvi'];}
					}
		
		echo $form->dropDownList($model,'madonviday',$khoa,array('empty'=>'')); ?></td>
		<td><?php echo $form->error($model,'madonviday'); ?></td>
	</tr>
	</div>
	
	<div class="row">
	<tr>
		<td><?php echo $form->labelEx($model,'nganh'); ?></td>
		<td><?php echo $form->textField($model,'nganh',array('size'=>60,'maxlength'=>128)); ?></td>
		<td><?php echo $form->error($model,'nganh'); ?></td>
	</tr>
	</div>

	<div class="row">
	<tr>
		<td><?php echo $form->labelEx($model,'he'); ?></td>
		<td><?php echo $form->dropDownList($model,'he',array('ĐH'=>'Đại học','CĐ'=>'Cao đẳng'),array('empty'=>'')); ?></td>
		<td><?php echo $form->error($model,'he'); ?></td>
	</tr>
	</div>

	<div class="row">
	<tr>
		<td><?php echo $form->labelEx($model,'ghichu'); ?></td>
		<td><?php echo $form->textArea($model,'ghichu',array('rows'=>6, 'cols'=>50)); ?></td>
		<td><?php echo $form->error($model,'ghichu'); ?></td>
	</tr>
	</div>
	</table>
	
	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Tạo mới' : 'Lưu'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->